/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.janalise.util;

import br.com.janalise.model.MapaDoTexto;
import br.com.janalise.model.Regra;
import java.util.Iterator;

/**
 *
 * @author boskyn9
 */
public class Validar {

    public static String sohLetras(String str) {
        str = str.replaceAll("[\\P{L}]", " ");
        str = RemoverStopList.remover(str);
        return str;
    }

    public static MapaDoTexto percentualValido(Float precente,MapaDoTexto mapa){
        Iterator<Regra> regras = mapa.getRegras().iterator();
        long max = mapa.getRegras().get(0).getOcorrencia();
        float valor = max * (precente * 0.01f);
        while (regras.hasNext()) {
            Regra regra = regras.next();
            if(regra.getOcorrencia()<valor){
                regras.remove();
            }
        }
        return mapa;
    }
}
